Hello altogether, perhaps a very silly question, but,... Is it possible to update the content of a canvas manually (means: triggering the (re-)paint routine)? Reason: I wrote a script which modifies the content of a canvas-string (using the draw(...)-function) as soon as the user has clicked within the canvas but the new content will not be shown. The reference manual says, that a canvas will only be updated when:
Unfortunately I found nothing like a refresh(), invalidate(), update()... function.
As a poor workaround I'm currently using these steps to force an update of the complete dialog:
// Force canvas update by resizing the dialog twice but this causes an ugly flickering.
I hope that anybody can explain me the best practise for this problem.
Best regards,
Michael MichaelBrockhaus - Mon Jun 08 08:58:00 EDT 2015 |
Re: How to update a canvas manually Hi Why don't you use a command like repaintMyWounderfulCanvas(); instead of all the other commands? Best regards Wolfgang |
Re: How to update a canvas manually Wolfgang Uhr - Mon Jun 08 10:10:04 EDT 2015 Hi Why don't you use a command like repaintMyWounderfulCanvas(); instead of all the other commands? Best regards Wolfgang Hello Wolfgang, I'm sorry, but I don't understand what you mean. My problem is not, that I don't want to see the "getSize->setSize" functions at this part of the code. So sourcing these lines out to another function probably wil not solve my problem. Best regards, Michael |
Re: How to update a canvas manually MichaelBrockhaus - Tue Jun 09 01:42:05 EDT 2015 Hello Wolfgang, I'm sorry, but I don't understand what you mean. My problem is not, that I don't want to see the "getSize->setSize" functions at this part of the code. So sourcing these lines out to another function probably wil not solve my problem. Best regards, Michael Hello Michael The canvas-declaration includes a routine:
DBE canvas(DB box, To implement a canvas you have to write the repaint-routine. There is not an other one. Instead of resizing you dialog you can define a global line DBE dbMyCanvas = null Somewhere in the code you write dbMyCanvas = canvas(dbMain, 100, 100, drawMyCanvas); And then you can use drawMyCanvas(dbMyCanvas); Best regards Wolfgang |
Re: How to update a canvas manually Wolfgang Uhr - Tue Jun 09 04:03:52 EDT 2015 Hello Michael The canvas-declaration includes a routine:
DBE canvas(DB box, To implement a canvas you have to write the repaint-routine. There is not an other one. Instead of resizing you dialog you can define a global line DBE dbMyCanvas = null Somewhere in the code you write dbMyCanvas = canvas(dbMain, 100, 100, drawMyCanvas); And then you can use drawMyCanvas(dbMyCanvas); Best regards Wolfgang Hello Wolfang, your described routine is exactly the one, I'm using (and as far as I know it's also the one and only available method to create a canvas). My problem is, that I'm not able to persuade DOORS that it has to repaint the canvas, now. Even if calling the repaint function manually, the achieved result is not the expected one (already displayed areas will not be updated). But I'm afraid that it's simply not possible. Thank you very much and best regards, Michael |
Re: How to update a canvas manually Can you post an example?
I tried a script with a DB, a canvas and a button and use the button to draw something on the canvas outside of repaint() function and it paints without a problem.
I assume you want to know how to clear the canvas so you can call repaint() and your own draw() function again... Have you considered drawing a big rectangle in the background color over everything? |
Re: How to update a canvas manually O.Wilkop - Tue Jun 09 10:54:01 EDT 2015 Can you post an example?
I tried a script with a DB, a canvas and a button and use the button to draw something on the canvas outside of repaint() function and it paints without a problem.
I assume you want to know how to clear the canvas so you can call repaint() and your own draw() function again... Have you considered drawing a big rectangle in the background color over everything? Actually it is difficult to post something, because IBM has done their best on this forum: --- DBE dbeArtBox = null; // This is a help file example! void doDrawing(DBE art) { int i, x, y, w, h int cw = width art int ch = height art for i in 0 : 15 do { color(art, i) x = random cw // size graphics to canvas y = random ch w = (cw - x) / 2 h = (ch - y) / 2 rectangle(art, x, y, w, h) } }
void dialogTest() { void doRepaint(DBE dbButton) { doDrawing(dbeArtBox); } DB dbtest = create("Test..."); dbeArtBox = canvas(dbtest, 400, 300, doDrawing); DBE dbeBtnRepaing = button(dbtest, "Repaint", doRepaint); block(dbtest); }
dialogTest(); ---- For me it works perfect ... |